import java.util.Stack;

public class testwork {
    public boolean IsPopOrder (int[] pushV, int[] popV) {
        // write code here
        Stack<Integer> stack=new Stack<>();
        int j=0;
        for(int i=0;i<pushV.length;i++){
            stack.push(pushV[i]);
            while(!stack.isEmpty()&&j<popV.length&&stack.peek()==popV[j]){
                stack.pop();
                j++;
            }
        }
        if(!stack.isEmpty()){
            return false;
        }
        return true;
    }
}
